using UnityEngine;

namespace ProjectSurvivor
{
    public class DamageSystem
    {
        public  static void CalculateDamage(float baseDamage,IEnemy enemy,int maxNormalDamage=2,float criticalDamageTimes=5)
        {
            if (Random.Range(0, 1.0f) < Global.CriticalRate.Value)
            {
                enemy.Hurt(baseDamage * Random.Range(2f, criticalDamageTimes) * Global.DamageRate.Value, false,true);
            }
            else
            {
                enemy.Hurt((baseDamage + Random.Range(-1, maxNormalDamage))*Global.DamageRate.Value);
            }
        }
    }
}
